﻿//-----------------------------------------------------------------------
// <copyright file="SmsComposeTask.cs" company="In The Hand Ltd">
//     Copyright © 2014 In The Hand Ltd. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Text;

namespace InTheHand.Phone.Tasks
{
    /// <summary>
    /// Launches the Messaging application with a new SMS message displayed.
    /// </summary>
    [Obsolete("Use InTheHand.ApplicationModel.Chat.ChatMessageManager", true)]
    public sealed class SmsComposeTask
    {
        /// <summary>
        /// Shows the Messaging application.
        /// </summary>
        public void Show()
        {
            // build uri
            StringBuilder sb = new StringBuilder();

            if(string.IsNullOrEmpty(To))
            {
                throw new InvalidOperationException();
            }
            else
            {
                sb.Append("sms:" + To);
            }

            /*if (!string.IsNullOrEmpty(Body))
            {
                sb.Append("?");
                sb.Append("body=" + Uri.EscapeDataString(Body));
            }*/

            Windows.System.Launcher.LaunchUriAsync(new Uri(sb.ToString()));

        }

        // <summary>
        // Gets or sets the body of the new SMS message.
        // </summary>
        //public string Body { set; get; }

        /// <summary>
        /// Gets or sets the recipients on the To line of the new SMS message.
        /// </summary>
        public string To { set; get; }
    }
}
